package com.fare.taluo.core.domain.system;

import java.util.Date;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.base.ddd.domain.baseentity.BaseEntity;

@javax.persistence.Entity
@Table(name = "VERSION_DETAILINFO")
@Cacheable
@Where(clause="FLG_DELETED=0")
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class VersionDetailInfoEntity extends BaseEntity{
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 6023968798916237357L;

	@Column(name = "SEQ_NUM")
	private Integer seq_Num;
	@Column(name = "CONTENT")
	private String content;
	@Column(name = "CREATER")
	private Long creater;
	@Column(name = "CREATE_TIME")
	private Date createTime = new Date();
	@Column(name = "FLG_DELETED")
	private Integer flgDeleted = 0;
	
	@JoinColumn(name = "VERSION_ID", referencedColumnName = "ID")
	@ManyToOne
	private VersionInfoEntity versionInfo;
	

	public VersionDetailInfoEntity(){}
	
	public VersionDetailInfoEntity(Integer seq_Num, String content,
			Long creater, VersionInfoEntity versionInfo) {
		super();
		this.seq_Num = seq_Num;
		this.content = content;
		this.creater = creater;
		this.versionInfo = versionInfo;
	}

	protected VersionDetailInfoEntityRepository getVersionDetailInfoEntityRepository() {
		return InstanceFactory
				.getInstance(VersionDetailInfoEntityRepository.class);
	}

	public Integer getFlgDeleted() {
		return flgDeleted;
	}

	public void setFlgDeleted(Integer flgDeleted) {
		this.flgDeleted = flgDeleted;
	}

	public List<VersionDetailInfoEntity> findVersionInfos(Long versionId) {
		return getVersionDetailInfoEntityRepository()
				.findVersionDetailInfoList(versionId);
	}

	public void saveOrUpdate(VersionDetailInfoEntity versionDetailInfoEntity) {
		getVersionDetailInfoEntityRepository().saveOrUpdate(
				versionDetailInfoEntity);
	}


	public Integer getSeq_Num() {
		return seq_Num;
	}

	public void setSeq_Num(Integer seq_Num) {
		this.seq_Num = seq_Num;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Long getCreater() {
		return creater;
	}

	public void setCreater(Long creater) {
		this.creater = creater;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public VersionInfoEntity getVersionInfo() {
		return versionInfo;
	}

	public void setVersionInfo(VersionInfoEntity versionInfo) {
		this.versionInfo = versionInfo;
	}

	@Override
	public String toString() {
		return "VersionDetailInfoEntity [seq_Num=" + seq_Num + ", content=" + content
				+ ", creater=" + creater + ", createTime=" + createTime
				+ ", flgDeleted=" + flgDeleted + "]";
	}
	
	
}
